<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Z-7
  Date: 2022/3/4
  Time: 18:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="${pageContext.request.contextPath}/resource/bootstrap4/css/bootstrap.css" rel="stylesheet">
    <script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jquery-3.2.1.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/resource/bootstrap-treeview/js/bootstrap-treeview.js"></script>
    <script src="${pageContext.request.contextPath}/resource/bootstrap4/js/bootstrap.js"></script>
    <title>基金列表</title>
</head>
<body>
    <blockquote class="blockquote text-center">
        <p class="mb-0">支付宝基金</p>
        <footer class="blockquote-footer">基金<cite title="Source Title">列表</cite></footer>
    </blockquote>
    <jsp:include page="../head.jsp"/>
    <form action="/funds/list" method="post"><input type="hidden" name="pageNum" value="${page.pageNum}"></form>
    <div class="container">
        <table class="table">
            <thead>
                <tr>
                    <th scope="col">基金编号</th>
                    <th scope="col">名称</th>
                    <th scope="col">类型</th>
                    <th scope="col">价格</th>
                    <th scope="col">基金经理</th>
                    <th scope="col">操作</th>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${page.list}" var="fund">
                    <tr>
                        <th scope="row">${fund.id}</th>
                        <td>${fund.name}</td>
                        <td>${fund.typeName}</td>
                        <td>${fund.price}</td>
                        <td>${fund.manager}</td>
                        <td>
                            <button type="button" class="btn btn-info" onclick="to_detail(${fund.id})">详情</button>
                            <button type="button" class="btn btn-info" onclick="to_add(${fund.id})">购买</button>
                        </td>
                    </tr>
                </c:forEach>
            </tbody>
            <tfoot>
            <tr>
                <td colspan="100">
                    <button type="button" class="btn btn-outline-dark" onclick="goPage(1)">首页</button>
                    <button type="button" class="btn btn-outline-dark" onclick="goPage(${page.pageNum == 1 ? 1 : page.pageNum - 1})">上一页</button>
                    <button type="button" class="btn btn-outline-dark" onclick="goPage(${page.pageNum == page.pages ? page.pages : page.pageNum + 1})">下一页</button>
                    <button type="button" class="btn btn-outline-dark" onclick="goPage(${page.pages})">尾页</button>
                    <button type="button" class="btn btn-outline-dark" onclick="exprotPDF(1)">预览PDF</button>
                    <button type="button" class="btn btn-outline-dark" onclick="exprotPDF(0)">导出PDF</button>
                </td>
            </tr>
            </tfoot>
        </table>
    </div>
<script type="text/javascript">
    function goPage(pageNum) {
       $("[name='pageNum']").val(pageNum);
       $("form").submit();
    }
    function to_add(id) {
        location="${pageContext.request.contextPath}/funds/to_add?id="+id;
    }
    function to_detail(id) {
        $('#myModal').modal('show')
        location="${pageContext.request.contextPath}/funds/detail?id="+id;
    }
    function exprotPDF(mode) {
        location="${pageContext.request.contextPath}/funds/exprotPDF?mode="+mode;
    }
</script>
</body>
</html>
